package com.orkasgb.framework.orkasgbframework.java.excel;

import jakarta.servlet.http.HttpServletResponse;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.time.LocalDate;
import java.util.Collections;
import java.util.List;

@RestController
@RequestMapping("/excelTest")
public class ExcelTestController {

    @GetMapping(value = "/exportExcel", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
    public void exportExcelTest(String id, HttpServletResponse response) throws IOException {
        ExcelTestEntity excelTestEntity = new ExcelTestEntity();
        excelTestEntity.setName("orkasgb");
        excelTestEntity.setSex("男");
        excelTestEntity.setBirthday(LocalDate.now());
        ExcelUtils.exportExcel(Collections.singletonList(excelTestEntity), "orkasgb", ExcelTestEntity.class, response);
    }

    public void importExcelTest() {

    }
}
